﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.levelup {
    import reprise.ui.*;
    import flash.display.*;
    import reprise.controls.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.utils.*;

    public class LevelUpPopupView extends AbstractPopupView {

        private var _titleLabel:Label;
        private var _closeButton:LabelButton;
        private var _responseButton:LabelButton;
        private var _animationDisplay:UIComponent;
        private var _descriptionLabel:Label;
        private var _contentDisplay:UIComponent;
        private var _graphicDisplay:UIComponent;
        private var _numbersMC:MovieClip;
        private var _receptionIcon:UIComponent;
        private var _youGetLabel:Label;
        private var _graphicMC:MovieClip;
        private var _levelLabelDisplay:UIComponent;
        private var _animationMovieClip:MovieClip;

        private static const NUMS:int = 3;

        public static var BUTTON_SHARE_ID:String = "share";
        public static var BUTTON_BUILD_ID:String = "build";

        override protected function initialize():void{
            cssID = "levelUpPopup";
            super.initialize();
        }
        override protected function createChildren():void{
            this._contentDisplay = addComponent("contentDisplay myriadProFont");
            this._animationDisplay = this._contentDisplay.addComponent("rewardStarsAnimation");
            this._animationMovieClip = AssetsLibrary.getMovieClip("RewardStars");
            this._animationDisplay.addChild(this._animationMovieClip);
            var _local1:UIComponent = this._contentDisplay.addComponent("background");
            this._graphicDisplay = _local1.addComponent("graphicDisplay");
            var _local2:UIComponent = _local1.addComponent("numberDisplay");
            this._numbersMC = AssetsLibrary.getMovieClip("LevelNumber");
            _local2.addChild(this._numbersMC);
            this._levelLabelDisplay = _local1.addComponent("levelLabelDisplay");
            this._receptionIcon = _local1.addComponent("receptionIcon");
            this._titleLabel = RepriseUtils.addLabel(_local1, "titleLabel");
            this._descriptionLabel = RepriseUtils.addLabel(_local1, "descriptionLabel");
            var _local3:UIComponent = _local1.addComponent("youGetLabelDisplay");
            this._youGetLabel = RepriseUtils.addLabel(_local3, "myriadProFontOutline youGetLabel");
            _local3.addComponent("rehaSportIcon");
            this._responseButton = RepriseUtils.addLabelButton(_local1, "respondsButton");
        }
        override public function show(... _args):void{
            this._contentDisplay.addCSSClass("show");
            this._animationDisplay.addChild(this._animationMovieClip);
            this._animationMovieClip.play();
        }
        override public function hide(... _args):void{
            this._contentDisplay.removeCSSClass("show");
            this._animationDisplay.removeChild(this._animationMovieClip);
            this._animationMovieClip.stop();
            this.disposeGraphic();
        }
        public function setResponseButtonLabel(_arg1:String, _arg2:String):void{
            this._responseButton.setData(_arg2);
            this._responseButton.setLabel(_arg1);
        }
        public function set level(_arg1:int):void{
            var _local3:MovieClip;
            var _local4:Object;
            var _local2:Array = _arg1.toString().split("");
            var _local5:int;
            while (_local5 < NUMS) {
                _local3 = this._numbersMC[("num_" + _local5)];
                if (_local5 < _local2.length){
                    _local4 = (int(_local2[_local5]) + 1);
                } else {
                    if (_local5 == _local2.length){
                        _local4 = "exclamation";
                    } else {
                        _local4 = "empty";
                    };
                };
                _local3.gotoAndStop(_local4);
                _local5++;
            };
        }
        public function setLanguage(_arg1:String):void{
            this._levelLabelDisplay.addCSSClass(_arg1);
        }
        public function set titleLabel(_arg1:String):void{
            this._titleLabel.setLabel(_arg1);
        }
        public function set descriptionLabel(_arg1:String):void{
            this._descriptionLabel.setLabel(_arg1);
        }
        public function set youGetLabel(_arg1:String):void{
            this._youGetLabel.setLabel(_arg1);
        }
        public function disposeGraphic():void{
            if (this._graphicMC){
                this._graphicMC.stop();
                this._graphicDisplay.removeChild(this._graphicMC);
                this._graphicMC = null;
            };
        }
        public function addLevelUpAnimation(_arg1:MovieClip):void{
            var _local4:Number;
            this._graphicMC = _arg1;
            var _local2 = 240;
            var _local3 = 330;
            if (this._graphicMC.height > _local2){
                _local4 = (_local2 / this._graphicMC.height);
                this._graphicMC.scaleX = (this._graphicMC.scaleY = _local4);
            };
            this._graphicMC.x = (Math.abs((_local3 - this._graphicMC.width)) / 2);
            this._graphicMC.y = -(this._graphicMC.height);
            this._graphicDisplay.addChild(this._graphicMC);
        }
        public function get closeButton():LabelButton{
            return (this._closeButton);
        }
        public function get respondsButton():LabelButton{
            return (this._responseButton);
        }

    }
}//package net.wooga.pets.views.popups.levelup 
